<?php
ini_set('error_reporting', 6143);
ini_set('display_errors','1');
define('IN_LC', true);
define('MM_ID', 1);

global $lang;
include_once("includes/database_query.php");
include_once("validate.php");
include_once("includes/style.php");
include_once("includes/addMessage.php");
include_once("includes/side_menu.php");



$style = new style(true);
$style->addRenderLeft(new side_menu('statistics'));

$url = 'statistics.php?';
if(isset($_GET['action']))
	$url .= 'action=' . $_GET['action'] .'&';

$filter = ' AND c_license = c_license';	
if(isset($_GET['license']) && is_numeric($_GET['license']))
{
	if($_GET['license'] > 0)
	{
		$filter = ' AND c_license = ' . $_GET['license'];	
	}
}
else
{
	$_GET['license'] = 0;
}

$filterMenu = '<br><br>' . $lang['ViewButton'] . ': ';

if($_GET['license'] == 0)
{
	$filterMenu .= $lang['AllEvents'] . ' ';
}
else
{
	$filterMenu .= '<a href="' . $url . 'license=0">' . $lang['AllEvents'] . '</a>';
} 

//get the licenses
$q = "SELECT l_id, l_name
	  FROM ". LICENSES_TABLE . "
	  ORDER BY l_order ASC";

$result = $db->sql_query($q);
while($l = $db->sql_fetchrow($result)) 
{
	if(isset($_GET['license']) && $_GET['license'] == $l['l_id'])
		$filterMenu .=  ' | ' . $l['l_name'];
	else
		$filterMenu .=  ' | <a href="' . $url . 'license=' . $l['l_id'] . '"> ' . $l['l_name'] . '</a>';
}

if(isset($_GET['action']) && $_GET['action'] == 'driverchamps')
{
	$mess = new addMessage($lang['StatisticsInfo'] . $filterMenu,$lang['ChampSignupDriver'] . ' ' . $lang['StatisticsMostChamps']);
	
	$query = 'SELECT  u_id, pf_drivername, count(*) as wincount
			  FROM ' . LCUSERS_TABLE . ', ' . HONOURENTRIES_TABLE . ', ' . 
			           HONOURCATS_TABLE . ', ' . DRIVERNAME_TABLE . ', ' .
					   DIVISIONS_TABLE . ', ' . CHAMPIONSHIPS_TABLE . '
			  WHERE user_id = u_id AND u_id = he_item AND d_champid = c_id AND he_rank = 1 AND 
			  		he_cat = hc_id AND hc_cat = 0 AND hc_division = d_id ' . $filter . '
					
			  GROUP BY u_id
			  ORDER BY wincount DESC, pf_drivername ASC
			  LIMIT 0, 30';
	$columns = Array($lang['ChampSignupDriver'], $lang['StatisticsMostChamps']);
	$columnValues = Array('<a href="drivers.php?id={u_id}">{pf_drivername}</a>', '{wincount}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}

else if(isset($_GET['action']) && $_GET['action'] == 'teamchamps')
{
	$mess = new addMessage($lang['StatisticsInfo'] . $filterMenu,$lang['ChampSignupTeam'] . ' ' . $lang['StatisticsMostChamps']);
	
	$query = 'SELECT p.t_id, p.t_name, count(*) as wincount
			FROM ' . TEAMS_TABLE . ' p, ' . TEAMS_TABLE . ' t, ' . HONOURENTRIES_TABLE . ', ' . HONOURCATS_TABLE . ', ' .
					 DIVISIONS_TABLE . ', ' . CHAMPIONSHIPS_TABLE . '
			WHERE (p.t_id = t.t_id OR p.t_id = t.t_parent) AND p.t_parent = 0 AND t.t_id = he_item AND 
				   he_rank = 1 AND he_cat = hc_id AND hc_cat = 1 AND d_champid = c_id AND hc_division = d_id ' . $filter . '
			GROUP BY p.t_id
			ORDER BY wincount DESC, t_name ASC LIMIT 0, 30';

	$columns = Array($lang['ChampSignupTeam'], $lang['StatisticsMostChamps']);
	$columnValues = Array('<a href="teams.php?id={t_id}">{t_name}</a>', '{wincount}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}

else if(isset($_GET['action']) && $_GET['action'] == 'driverpodiums')
{
	$mess = new addMessage($lang['StatisticsInfo'] . $filterMenu,$lang['ChampSignupDriver'] . ' ' . $lang['StatisticsMostPodiums']);
	
	$query = 'SELECT  u_id, pf_drivername, count(*) as wincount
			  FROM ' . LCUSERS_TABLE . ', ' . RACERESULTS_TABLE . ', ' . DRIVERNAME_TABLE . ', ' .
					   EVENTS_TABLE . ', ' . CHAMPIONSHIPS_TABLE . '
			  WHERE user_id = u_id AND r_driver = u_id AND r_raceposition < 4 AND 
			  		r_raceposition > 0 AND e_id = r_event AND e_championship = c_id ' . $filter . '
			  GROUP BY u_id
			  ORDER BY wincount DESC, pf_drivername ASC
			  LIMIT 0, 30';
	$columns = Array($lang['ChampSignupDriver'], $lang['StatisticsMostPodiums']);
	$columnValues = Array('<a href="drivers.php?id={u_id}">{pf_drivername}</a>', '{wincount}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}

else if(isset($_GET['action']) && $_GET['action'] == 'teampodiums')
{
	$mess = new addMessage($lang['StatisticsInfo'] . $filterMenu,$lang['ChampSignupTeam'] . ' ' . $lang['StatisticsMostPodiums']);
	
	$query = 'SELECT  p.t_id, p.t_name, count(*) as wincount
			  FROM ' . TEAMS_TABLE . ' p, ' . TEAMS_TABLE . ' t, ' . RACERESULTS_TABLE . ', ' . EVENTSIGNUPS_TABLE . ', ' .
					   EVENTS_TABLE . ', ' . CHAMPIONSHIPS_TABLE . '
			  WHERE (p.t_id = t.t_id OR p.t_id = t.t_parent) AND p.t_parent = 0 AND t.t_id = es_team AND r_driver = es_driver AND 
			  		r_event = es_event AND r_raceposition < 4 AND r_raceposition > 0 AND e_id = r_event AND e_championship = c_id ' . $filter . '
			  GROUP BY p.t_id
			  ORDER BY wincount DESC, t_name ASC
			  LIMIT 0, 30';
	$columns = Array($lang['ChampSignupTeam'], $lang['StatisticsMostPodiums']);
	$columnValues = Array('<a href="teams.php?id={t_id}">{t_name}</a>', '{wincount}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}

else if(isset($_GET['action']) && $_GET['action'] == 'driverfastest')
{
	$mess = new addMessage($lang['StatisticsInfo'] . $filterMenu,$lang['ChampSignupDriver'] . ' ' . $lang['StatisticsMostFastest']);
	
	$query = 'SELECT  u_id, pf_drivername, count(*) as wincount
			  FROM ' . LCUSERS_TABLE . ', ' . RACERESULTS_TABLE . ', ' . DRIVERNAME_TABLE . ', ' .
					   EVENTS_TABLE . ', ' . CHAMPIONSHIPS_TABLE . '
			  WHERE user_id = u_id AND r_driver = u_id AND r_fastestlap_rank = 1 AND e_id = r_event AND e_championship = c_id ' . $filter . '
			  GROUP BY u_id
			  ORDER BY wincount DESC, pf_drivername ASC
			  LIMIT 0, 30';
	$columns = Array($lang['ChampSignupDriver'], $lang['StatisticsMostFastest']);
	$columnValues = Array('<a href="drivers.php?id={u_id}">{pf_drivername}</a>', '{wincount}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}

else if(isset($_GET['action']) && $_GET['action'] == 'teamfastest')
{
	$mess = new addMessage($lang['StatisticsInfo'] . $filterMenu,$lang['ChampSignupTeam'] . ' ' . $lang['StatisticsMostFastest']);
	
	$query = 'SELECT  p.t_id, p.t_name, count(*) as wincount
			  FROM ' . TEAMS_TABLE . ' p, ' . TEAMS_TABLE . ' t, ' . RACERESULTS_TABLE . ', ' . EVENTSIGNUPS_TABLE . ', ' .
					   EVENTS_TABLE . ', ' . CHAMPIONSHIPS_TABLE . '
			  WHERE (p.t_id = t.t_id OR p.t_id = t.t_parent) AND p.t_parent = 0 AND t.t_id = es_team AND r_driver = es_driver AND 
			  		r_event = es_event AND r_fastestlap_rank = 1 AND e_id = r_event AND e_championship = c_id ' . $filter . '
			  GROUP BY p.t_id
			  ORDER BY wincount DESC, t_name ASC
			  LIMIT 0, 30';
	$columns = Array($lang['ChampSignupTeam'], $lang['StatisticsMostFastest']);
	$columnValues = Array('<a href="teams.php?id={t_id}">{t_name}</a>', '{wincount}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}

else if(isset($_GET['action']) && $_GET['action'] == 'driverpoles')
{
	$mess = new addMessage($lang['StatisticsInfo'] . $filterMenu,$lang['ChampSignupDriver'] . ' ' . $lang['StatisticsMostPoles']);
	
	$query = 'SELECT  u_id, pf_drivername, count(*) as wincount
			  FROM ' . LCUSERS_TABLE . ', ' . RACERESULTS_TABLE . ', ' . DRIVERNAME_TABLE . ', ' .
					   EVENTS_TABLE . ', ' . CHAMPIONSHIPS_TABLE . '
			  WHERE user_id = u_id AND r_driver = u_id AND r_qualifyingrank = 1 AND e_id = r_event AND e_championship = c_id ' . $filter . '
			  GROUP BY u_id
			  ORDER BY wincount DESC, pf_drivername ASC
			  LIMIT 0, 30';
	$columns = Array($lang['ChampSignupDriver'], $lang['StatisticsMostPoles']);
	$columnValues = Array('<a href="drivers.php?id={u_id}">{pf_drivername}</a>', '{wincount}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}

else if(isset($_GET['action']) && $_GET['action'] == 'teampoles')
{
	$mess = new addMessage($lang['StatisticsInfo'] . $filterMenu,$lang['ChampSignupTeam'] . ' ' . $lang['StatisticsMostPoles']);
	
	$query = 'SELECT  p.t_id, p.t_name, count(*) as wincount
			  FROM ' . TEAMS_TABLE . ' p, ' . TEAMS_TABLE . ' t, ' . RACERESULTS_TABLE . ', ' . EVENTSIGNUPS_TABLE . ', ' .
					   EVENTS_TABLE . ', ' . CHAMPIONSHIPS_TABLE . '
			  WHERE (p.t_id = t.t_id OR p.t_id = t.t_parent) AND p.t_parent = 0 AND t.t_id = es_team AND r_driver = es_driver AND 
			        r_event = es_event AND r_qualifyingrank = 1 AND e_id = r_event AND e_championship = c_id ' . $filter . '
			  GROUP BY p.t_id
			  ORDER BY wincount DESC, t_name ASC
			  LIMIT 0, 30';
	$columns = Array($lang['ChampSignupTeam'], $lang['StatisticsMostPoles']);
	$columnValues = Array('<a href="teams.php?id={t_id}">{t_name}</a>', '{wincount}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}

else if(isset($_GET['action']) && $_GET['action'] == 'driverpoints')
{
	$mess = new addMessage($lang['StatisticsInfo'] . $filterMenu,$lang['ChampSignupDriver'] . ' ' . $lang['StatisticsMostPoints']);
	
	$query = 'SELECT  u_id, pf_drivername, sum(r_points) as wincount
			  FROM ' . LCUSERS_TABLE . ', ' . RACERESULTS_TABLE . ', ' . DRIVERNAME_TABLE . ', ' .
					   EVENTS_TABLE . ', ' . CHAMPIONSHIPS_TABLE . '
			  WHERE user_id = u_id AND r_driver = u_id AND e_id = r_event AND e_championship = c_id ' . $filter . '
			  GROUP BY u_id
			  ORDER BY wincount DESC, pf_drivername ASC
			  LIMIT 0, 30';
	$columns = Array($lang['ChampSignupDriver'], $lang['StatisticsMostPoints']);
	$columnValues = Array('<a href="drivers.php?id={u_id}">{pf_drivername}</a>', '{wincount}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}

else if(isset($_GET['action']) && $_GET['action'] == 'teampoints')
{
	$mess = new addMessage($lang['StatisticsInfo'] . $filterMenu,$lang['ChampSignupTeam'] . ' ' . $lang['StatisticsMostPoints']);
	
	$query = 'SELECT  p.t_id, p.t_name, sum(r_points) as wincount
			  FROM ' . TEAMS_TABLE . ' p, ' . TEAMS_TABLE . ' t, ' . RACERESULTS_TABLE . ', ' . EVENTSIGNUPS_TABLE . ', ' .
					   EVENTS_TABLE . ', ' . CHAMPIONSHIPS_TABLE . '
			  WHERE (p.t_id = t.t_id OR p.t_id = t.t_parent) AND p.t_parent = 0 AND t.t_id = es_team AND r_driver = es_driver AND 
			        r_event = es_event AND e_id = r_event AND e_championship = c_id ' . $filter . '
			  GROUP BY p.t_id
			  ORDER BY wincount DESC, t_name ASC
			  LIMIT 0, 30';
	$columns = Array($lang['ChampSignupTeam'], $lang['StatisticsMostPoints']);
	$columnValues = Array('<a href="teams.php?id={t_id}">{t_name}</a>', '{wincount}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}

else if(isset($_GET['action']) && $_GET['action'] == 'driverraces')
{
	$mess = new addMessage($lang['StatisticsInfo'] . $filterMenu,$lang['ChampSignupDriver'] . ' ' . $lang['StatisticsMostRaces']);
	
	$query = 'SELECT  u_id, pf_drivername, count(*) as wincount
			  FROM ' . LCUSERS_TABLE . ', ' . RACERESULTS_TABLE . ', ' . DRIVERNAME_TABLE . ', ' .
					   EVENTS_TABLE . ', ' . CHAMPIONSHIPS_TABLE . '
			  WHERE user_id = u_id AND r_driver = u_id AND e_id = r_event AND e_championship = c_id ' . $filter . '
			  GROUP BY u_id
			  ORDER BY wincount DESC, pf_drivername ASC
			  LIMIT 0, 30';
	$columns = Array($lang['ChampSignupDriver'], $lang['StatisticsMostRaces']);
	$columnValues = Array('<a href="drivers.php?id={u_id}">{pf_drivername}</a>', '{wincount}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}

else if(isset($_GET['action']) && $_GET['action'] == 'teamraces')
{
	$mess = new addMessage($lang['StatisticsInfo'] . $filterMenu,$lang['ChampSignupTeam'] . ' ' . $lang['StatisticsMostRaces']);
	
	$query = 'SELECT  p.t_id, p.t_name, count(*) as wincount
			  FROM ' . TEAMS_TABLE . ' p, ' . TEAMS_TABLE . ' t, ' . RACERESULTS_TABLE . ', ' . EVENTSIGNUPS_TABLE . ', ' .
					   EVENTS_TABLE . ', ' . CHAMPIONSHIPS_TABLE . '
			  WHERE (p.t_id = t.t_id OR p.t_id = t.t_parent) AND p.t_parent = 0 AND t.t_id = es_team AND r_driver = es_driver AND 
			  		r_event = es_event AND e_id = r_event AND e_championship = c_id ' . $filter . '
			  GROUP BY p.t_id
			  ORDER BY wincount DESC, t_name ASC
			  LIMIT 0, 30';
	$columns = Array($lang['ChampSignupTeam'], $lang['StatisticsMostRaces']);
	$columnValues = Array('<a href="teams.php?id={t_id}">{t_name}</a>', '{wincount}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}

else if(isset($_GET['action']) && $_GET['action'] == 'driverlaps')
{
	$mess = new addMessage($lang['StatisticsInfo'] . $filterMenu,$lang['ChampSignupDriver'] . ' ' . $lang['StatisticsMostLaps']);
	
	$query = 'SELECT  u_id, pf_drivername, sum(r_racelaps) as wincount
			  FROM ' . LCUSERS_TABLE . ', ' . RACERESULTS_TABLE . ', ' . DRIVERNAME_TABLE . ', ' .
					   EVENTS_TABLE . ', ' . CHAMPIONSHIPS_TABLE . '
			  WHERE user_id = u_id AND r_driver = u_id AND e_id = r_event AND e_championship = c_id ' . $filter . '
			  GROUP BY u_id
			  ORDER BY wincount DESC, pf_drivername ASC
			  LIMIT 0, 30';
	$columns = Array($lang['ChampSignupDriver'], $lang['StatisticsMostLaps']);
	$columnValues = Array('<a href="drivers.php?id={u_id}">{pf_drivername}</a>', '{wincount}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}

else if(isset($_GET['action']) && $_GET['action'] == 'drivertime')
{
	$mess = new addMessage($lang['StatisticsInfo'] . $filterMenu,$lang['ChampSignupDriver'] . ' ' . $lang['StatisticsMostTime']);
	
	$query = 'SELECT  u_id, pf_drivername, SEC_TO_TIME(sum(r_racetime)/1000) as wincount
			  FROM ' . LCUSERS_TABLE . ', ' . RACERESULTS_TABLE . ', ' . DRIVERNAME_TABLE . ', ' .
					   EVENTS_TABLE . ', ' . CHAMPIONSHIPS_TABLE . '
			  WHERE user_id = u_id AND r_driver = u_id AND r_racetime != ' . RACETIME_DNF . ' AND 
			  		e_id = r_event AND e_championship = c_id ' . $filter . '
			  GROUP BY u_id
			  ORDER BY wincount DESC, pf_drivername ASC
			  LIMIT 0, 30';
	$columns = Array($lang['ChampSignupDriver'], $lang['StatisticsMostTimeTable']);
	$columnValues = Array('<a href="drivers.php?id={u_id}">{pf_drivername}</a>', '{wincount}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}

else if(isset($_GET['action']) && $_GET['action'] == 'driverlicense')
{
	$mess = new addMessage($lang['StatisticsInfo'],$lang['ChampSignupDriver'] . ' ' . $lang['StatisticsMostLicensePoints']);
	
	$query = 'SELECT  user_id, pf_drivername, u_licensePoints as pointcount
			  FROM ' .  LCUSERS_TABLE . ', ' . DRIVERNAME_TABLE . '
			  WHERE user_id = u_id AND u_licensePoints > 0
			  ORDER BY pointcount DESC, pf_drivername ASC';
	$columns = Array($lang['ChampSignupDriver'], $lang['StatisticsMostLicensePoints']);
	$columnValues = Array('<a href="drivers.php?id={user_id}&mode=license">{pf_drivername}</a>', '{pointcount}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}

else if(isset($_GET['action']) && $_GET['action'] == 'teamwins')
{
	$mess = new addMessage($lang['StatisticsInfo'] . $filterMenu,$lang['ChampSignupTeam'] . ' ' . $lang['StatisticsMostWins']);
	
	$query = 'SELECT  p.t_id, p.t_name, count(*) as wincount
			  FROM ' . TEAMS_TABLE . ' p, ' . TEAMS_TABLE . ' t, ' . RACERESULTS_TABLE . ', ' . EVENTSIGNUPS_TABLE . ', ' .
					   EVENTS_TABLE . ', ' . CHAMPIONSHIPS_TABLE . '
			  WHERE (p.t_id = t.t_id OR p.t_id = t.t_parent) AND p.t_parent = 0 AND t.t_id = es_team AND r_driver = es_driver AND 
			  		r_event = es_event AND r_raceposition = 1 AND e_id = r_event AND e_championship = c_id ' . $filter . '
			  GROUP BY p.t_id
			  ORDER BY wincount DESC, t_name ASC
			  LIMIT 0, 30';
	$columns = Array($lang['ChampSignupTeam'], $lang['StatisticsMostRaces']);
	$columnValues = Array('<a href="teams.php?id={t_id}">{t_name}</a>', '{wincount}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}

else if(isset($_GET['action']) && $_GET['action'] == 'driverwins')
{
	$mess = new addMessage($lang['StatisticsInfo'] . $filterMenu,$lang['ChampSignupDriver'] . ' ' . $lang['StatisticsMostWins']);
	
	$query = 'SELECT  u_id, pf_drivername, count(*) as wincount
			  FROM ' . LCUSERS_TABLE . ', ' . RACERESULTS_TABLE . ', ' . DRIVERNAME_TABLE . ', ' .
					   EVENTS_TABLE . ', ' . CHAMPIONSHIPS_TABLE . '
			  WHERE user_id = u_id AND r_driver = u_id AND r_raceposition = 1 AND e_id = r_event AND e_championship = c_id ' . $filter . '
			  GROUP BY u_id
			  ORDER BY wincount DESC, pf_drivername ASC
			  LIMIT 0, 30';
	$columns = Array($lang['ChampSignupDriver'], $lang['StatisticsMostWins']);
	$columnValues = Array('<a href="drivers.php?id={u_id}">{pf_drivername}</a>', '{wincount}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}

else if(isset($_GET['action']) && $_GET['action'] == 'driverbans')
{
	$mess = new addMessage($lang['StatisticsBansInfo'],$lang['ChampSignupDriver'] . ' ' . $lang['StatisticsBans']);
	
	$query = 'SELECT  b_user, pf_drivername, b_comment, date_format(b_startDate, "%b %e, %Y") as b_startDateF, 
					  date_format(b_endDate, "%b %e, %Y") as b_endDateF, COALESCE(l_name,"' . $lang['AllEvents'] . '") as l_name
			  FROM ' .  DRIVERNAME_TABLE . ', ' . BANS_TABLE . ' LEFT JOIN ' . LICENSES_TABLE . ' ON b_license = l_id 
			  WHERE b_user = user_id
			  ORDER BY b_startDate DESC, b_endDate DESC, pf_drivername ASC';
			  
	$columns = Array($lang['ChampSignupDriver'], $lang['BanStartDate'], $lang['BanEndDate'], $lang['Events'], '');
	$columnWidths = Array('19%', '13%', '13%', '15%', '40%');
	$columnValues = Array('<a href="drivers.php?id={b_user}&mode=license">{pf_drivername}</a>', '{b_startDateF}', '{b_endDateF}', '{l_name}', '{b_comment}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, false, $columnWidths));
}

else
{
	$mess = new addMessage($lang['StatisticsInfo'],$lang['ChampSignupDriver'] . ' ' . $lang['StatisticsRanking']);
	
	$query = 'SELECT  u_id, pf_drivername, u_rankingPoints
			  FROM ' . LCUSERS_TABLE . ', ' . DRIVERNAME_TABLE . ' d, ' . USERSGROUPS_TABLE . ' g
			  WHERE g.user_id = d.user_id AND d.user_id = u_id AND u_rankingPoints > 0 AND g.group_id = 3
			  GROUP BY u_id
			  ORDER BY u_rankingPoints DESC, pf_drivername ASC';
	$columns = Array($lang['ChampSignupDriver'], $lang['StatisticsRanking']);
	$columnValues = Array('<a href="drivers.php?id={u_id}">{pf_drivername}</a>', '{u_rankingPoints}');
	
	$style->addRenderRight(new database_query($mess,  $query, $columns, $columnValues, true));
}
$style->render();
echo $db->num_queries;
?>